package com.mq.delay;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 队列中消息不被消费才会到死信队列中，从而实现延迟消息
 * @author ytj
 * @date 2024/1/16
 */
@Component
public class Demo8Consumer {

    @RabbitHandler
    @RabbitListener(queues = Demo8Message.DELAY_QUEUE)
    public void delaymessage(Demo8Message demo8Message){
        System.out.println("当前时间:"+(int)System.currentTimeMillis()/1000);
        System.out.println("延迟队列获取发送消息:"+demo8Message.getId());
    }
}
